package com.omega.encryptedsql.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.omega.encryptedsql.handler.SmartEncryptTypeHandler;
import com.omega.encryptedsql.po.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {

   /* *//**
     * 自定义查询，指定字段不解密
     *//*
    @Select("SELECT id, name, email, phone FROM t_employee WHERE department = #{dept}")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "email", property = "email",
                    typeHandler = SmartEncryptTypeHandler.class), // 自动解密
            @Result(column = "phone", property = "phone") // 不解密
    })
    List<Employee> findByDepartment(@Param("dept") String department);*/

    /**
     * 使用XML配置的复杂查询
     */
    List<Employee> selectComplexQuery(@Param("minAge") int minAge,
                                      @Param("startDate") String startDate);

    List<Employee> searchWithName(@Param("name") String name);
}
